app.controller('btnCtrl', ['$scope', '$http', BtnController]);
function BtnController($scope, $http){
    console.log('------$scope.menuId1-----', $scope.menuId);
    console.log('------$scope.buttonArr1-----', $scope.buttonArr);

    $scope.bindBtn = function(event) {
        var datas = $scope.getSelectedRows();
        var t = this;
        switch(event){
            //上传至知识库
            case 'event-to-addToLedge':
            {
                if(datas.length == 0) {
                    layer.alert('尚未选中数据');
                    return;
                }
                var ids = '';
                for(var i=0;i<datas.length;i++){
                    if(ids==''){
                        ids = datas[i].id;
                    }else {
                        ids = ids+','+datas[i].id;
                    }
                }
                $scope.showModalLink('/web/eKnowAi/webEKnowAiController/chatLogManageUpload?id='+ids, '选择要上传的知识库分类');
                break;
            }
            case 'event-to-del':
            {
                if(datas.length == 0) {
                    layer.alert('尚未选中数据');
                } else {
                    var ids = '';
                    for(var i=0;i<datas.length;i++){
                        if(ids==''){
                            ids = datas[i].id;
                        }else {
                            ids = ids+','+datas[i].id;
                        }
                    }

                    layer.confirm('确定要删除选中的日志吗？', {icon: 3}, function () {
                        layer.msg('处理中', {
                            icon: 16,shade: 0.01
                        });
                        console.log('ids',ids);
                        $http.post('/api/inter/eKnowChatLogManage/delChatLogManageByBatch', {}, {params: {ids: ids}})
                            .success(function (result) {
                                if(result.code=='SUCCESS'){
                                    layer.close();
                                    location.reload();
                                    layer.msg("操作成功");
                                }else {//失败
                                    layer.close();
                                    layer.msg(result.msg, {icon: 2});
                                }
                            })
                            .error(function(result){
                                layer.close();
                                layer.msg("删除失败，请稍后再试！", {icon: 2});
                            });

                    }, function () {});

                }
                break;
            }
        };
    }
}
